package com.mcptt.config.model;

import com.cloudptt.api.pjsip.api.ImsProfile;
import com.cloudptt.api.product.log.Log;
import com.mcptt.db.model.UserInfo;




public class McpttLoginInfo
{
	private BootStrapSvrInfo bootStrapSvr = null;
	private ImsInfo imsInfo = null;
	private McIdInfo mcIdInfo = null;
//	private String defaultGroupId = null;
//	private String curGroupId = null;

	public McpttLoginInfo(BootStrapSvrInfo bootStrapSvr, ImsInfo imsInfo, McIdInfo mcpttInfo)
	{
		this.bootStrapSvr = bootStrapSvr;
		this.imsInfo = imsInfo;
		this.mcIdInfo = mcpttInfo;
//		this.defaultGroupId = defaultGroupId;
	}
	
//	public String getDefaultGroupId() {
//		return defaultGroupId;
//	}
//
//	public void setDefaultGroupId(String defaultGroupId) {
//		this.defaultGroupId = defaultGroupId;
//	}
//
//	public String getCurGroupId() {
//		if(curGroupId == null)
//		{
//			return defaultGroupId;
//		}
//		return curGroupId;
//	}
//
//	public void setCurGroupId(String curGroupId) {
//		this.curGroupId = curGroupId;
//	}

	public BootStrapSvrInfo getBootStrapSvr()
	{
		return bootStrapSvr;
	}

	public boolean isInputedUser()
	{
		Log.debug(this.getClass(),"isInputedUser imsInfo =  " + imsInfo);
		if(this.imsInfo == null
				|| this.imsInfo.isInvalid())
		{
			return true;
		}
//		Log.debug(this.getClass(),"isInputedUser mcIdInfo = " + mcIdInfo);
//		if(this.mcIdInfo == null
//				|| this.mcIdInfo.isInvalid())
//		{
//			return true;
//		}
//		Log.debug(this.getClass(),"isInputedUser 3");
		//		if(this.accessToken == null
		//				|| this.accessToken.length() <= 0)
		//		{
		//			return true;
		//		}
		return false;
	}

	public boolean isInvalidUser()
	{
		Log.debug(this.getClass(),"isInvalidUser imsInfo =  " + imsInfo);
		if(this.imsInfo == null
				|| this.imsInfo.isInvalid())
		{
			return true;
		}
		Log.debug(this.getClass(),"isInvalidUser mcIdInfo = " + mcIdInfo);
		if(this.mcIdInfo == null
				|| this.mcIdInfo.isInvalid())
		{
			return true;
		}
		Log.debug(this.getClass(),"isInvalidUser 3");
		//		if(this.accessToken == null
		//				|| this.accessToken.length() <= 0)
		//		{
		//			return true;
		//		}
		return false;
	}

	public void clearMcpttLoginInfo()
	{
		Log.debug(this.getClass(),"clearMcpttLoginInfo");
//		bootStrapSvr = null;
		imsInfo = null;
		mcIdInfo = null;
//		defaultGroupNum = null;
//		curGroupId = null;
	}
	public ImsInfo getImsInfo()
	{
		return imsInfo;
	}

	public McIdInfo getMcIdInfo()
	{
		return mcIdInfo;
	}

	public UserInfo toUserInfo()
	{
		return mcIdInfo.toUserInfo();
	}

	//    public String getAccessToken()
	//    {
	//        return accessToken;
	//    }
	public ImsProfile toImsProfile()
	{
		ImsProfile profile = new ImsProfile(mcIdInfo,imsInfo);
		return profile;
	}

	public String toString()
	{
		StringBuffer buffer = new StringBuffer("McpttLoginInfo:");
		buffer.append("bootStrapSvr = ").append(bootStrapSvr).append(",");
		buffer.append("imsInfo = ").append(imsInfo).append(",");
		buffer.append("mcpttInfo = ").append(mcIdInfo).append(";");

		return buffer.toString();
	}


}
